﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Deployment.Application;

namespace Transferomatic.Views
{
    public partial class UpdateNotificationView : Form
    {
        #region Properties
        public LinkLabel LinkLabel
        {
            get { return this._LinkLabel; }
        }

        public Timer timerCheckForUpdate
        {
            get { return this._timerCheckForUpdate; }
        }

        public Timer timerHideStatusWindow
        {
            get { return this._timerHideStatusWindow; }
        }
        #endregion

        #region Methods
        public UpdateNotificationView()
        {
            InitializeComponent();

            this.Left =
                Screen.PrimaryScreen.WorkingArea.Right - this.Width;
            this.Top =
                Screen.PrimaryScreen.Bounds.Bottom + this.Height;

            this._LinkLabel.Text = String.Format(
                CultureInfo.CurrentCulture,
                "An update is available for {0}{1}Click here to update ...",
                Application.ProductName,
                Environment.NewLine);

            this._timerCheckForUpdate.Interval = 1000 * 60 * 60; // 1 hour
            this._timerHideStatusWindow.Interval = 1000 * 30; // 30 seconds
        }

        #region Private Helpers
        public void ShowStatusWindow()
        {
            this.Top =
                Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;

            Application.DoEvents();

            this._timerHideStatusWindow.Start();
        }

        public void HideStatusWindow()
        {
            this.Top =
                Screen.PrimaryScreen.WorkingArea.Bottom + this.Height;

            Application.DoEvents();

            this._timerHideStatusWindow.Stop();
        }
        #endregion
        #endregion
    }
}
